﻿Public Class Login
    Sub gir()
        If tbKullaniciAdi.Text = "a" And tbSifre.Text = "1" Then
            Me.Hide()
            tbKullaniciAdi.Text = "Kullanıcı Adı"
            tbSifre.Text = "Şifre"
            Admin.Show()
        Else
            Dim kontrol = Sorgula("select * from merkezlersubeler where kullaniciadi = '" & temizle(tbKullaniciAdi.Text) & "' and sifre='" & temizle(tbSifre.Text) & "'")
            If kontrol.Rows.Count < 1 Then
                MsgBox("Kullanıcı Adı veya Şifre Hatalı!", MsgBoxStyle.Exclamation)
                Return
            Else
                tbKullaniciAdi.Text = "Kullanıcı Adı"
                tbSifre.Text = "Şifre"                
                Me.Hide()
                Dim merkezmi = kontrol.Rows(0)("merkezmi")
                Dim id = kontrol.Rows(0)("ID")
                Dim adi = kontrol.Rows(0)("Adi")

                If merkezmi Then
                    Dim merkezekrani As New MerkezEkran
                    merkezekrani.MerkezBelirle(id, adi, True)
                    merkezekrani.Show()
                Else
                    Dim subeekrani As New SubeEkran
                    subeekrani.SubeSec(id, adi, True)
                    subeekrani.Show()

                End If
            End If
        End If
    End Sub

    Private Sub btnGiris_Click(sender As Object, e As EventArgs) Handles btnGiris.Click
        gir()

    End Sub

    Private Sub tbKullaniciAdi_MouseClick(sender As Object, e As MouseEventArgs) Handles tbKullaniciAdi.MouseClick
        If tbKullaniciAdi.Text = "Kullanıcı Adı" Then tbKullaniciAdi.Text = ""
    End Sub

    Private Sub tbSifre_MouseClick(sender As Object, e As MouseEventArgs) Handles tbSifre.MouseClick
        If tbSifre.Text = "Şifre" Then tbSifre.Text = ""
    End Sub

    Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Location = New Point(Screen.PrimaryScreen.Bounds.Width / 2 - Me.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2 - Me.Height / 2)


    End Sub

    Private Sub tbSifre_KeyPress(sender As Object, e As KeyPressEventArgs) Handles tbSifre.KeyPress, tbKullaniciAdi.KeyPress
        If Convert.ToInt32(e.KeyChar) = Keys.Enter Then
            gir()

        End If
    End Sub

End Class